<template>
  <div class="thematic-map">
    <div class="settingC_thematic">
      <div class="settingC_title1">
        <span>专题图生成</span>
      </div>
      <el-scrollbar class="settingC_thematic_C scroll-container">
        <div class="settingC_thematic_C_item" @click="thematicClick(thematicOptions[3], 3)">
          <div class="settingC_thematic_C_item_icon"></div>
          <div class="settingC_thematic_C_item_name">生成专题图
          </div>
        </div>
        <div class="settingC_thematic_C_item" @click="thematicClick(thematicOptions[0], 0)">
          <div class="settingC_thematic_C_item_icon"
            :style="{ 'background-image': thematicOptions[0].status ? `url(${require('@/assets/zfx_s.png')})` : `url(${require('@/assets/zfx.png')})` }">
          </div>
          <div class="settingC_thematic_C_item_name">企业分布
          </div>
        </div>
        <div class="settingC_thematic_C_item" @click="thematicClick(thematicOptions[1], 1)">
          <div class="settingC_thematic_C_item_icon"
            :style="{ 'background-image': thematicOptions[1].status ? `url(${require('@/assets/zfx_s.png')})` : `url(${require('@/assets/zfx.png')})` }">
          </div>
          <div class="settingC_thematic_C_item_name">传感器分布
          </div>
        </div>
        <div class="settingC_thematic_C_item" v-for="(item, index) in sensorOptions" :key="index"
          @click="sensorClick(item, index)">
          <div class="settingC_thematic_C_item_iconc  "
            :style="{ 'background-image': item.status ? `url(${require('@/assets/zfx_s.png')})` : `url(${require('@/assets/zfx.png')})` }">
          </div>
          <div class="settingC_thematic_C_item_name">
            {{ item.label }}
          </div>
        </div>
        <div class="settingC_thematic_C_item" @click="thematicClick(thematicOptions[2], 2)">
          <div class="settingC_thematic_C_item_icon"
            :style="{ 'background-image': thematicOptions[2].status ? `url(${require('@/assets/zfx_s.png')})` : `url(${require('@/assets/zfx.png')})` }">
          </div>
          <div class="settingC_thematic_C_item_name">监控分布
          </div>
        </div>
        <div class="settingC_thematic_C_item" v-for="(item, index) in controlOptions" :key="index"
          @click="controlClick(item, index)">
          <div class="settingC_thematic_C_item_iconc  "
            :style="{ 'background-image': item.status ? `url(${require('@/assets/zfx_s.png')})` : `url(${require('@/assets/zfx.png')})` }">
          </div>
          <div class="settingC_thematic_C_item_name">
            {{ item.label }}
          </div>
        </div>
      </el-scrollbar>
    </div>
  </div>
</template>
<script>
import {
  sendDistributionMsg,
  sendEquipment0Msg,
  sendEquipment1Msg,
  sendscreenshotMsg,
} from "@/utils/UeMessageUtils";

export default {
  name: 'thematic-map',
  data() {
    return {};
  },
  methods: {
    thematicClick(value, index) {
      this.resetRoam()
      this.resetModel()
      var time = new Date().getTime()
      if (index == 3) {
        if (time - this.intervalTime > 3 * 1000) {
          this.intervalTime = time
          this.$message.success('专题图已保存到/NM_SHM_UE5/Saved/Screenshots/Windows目录下')
          sendscreenshotMsg(1)
        }

        return
      }
      this.thematicOptions.forEach(item => {
        if (item != value) {
          item.status = false
        }
      })
      value.status = !value.status
      if (index == 1) {
        // sendSensorMsg(1)
        this.controlOptions.forEach(item => {
          item.status = false
          sendEquipment0Msg(item.flag)
        })
        if (value.status) {
          this.sensorOptions.forEach(item => {
            item.status = true
            sendEquipment1Msg(item.flag)
          })
        } else {
          this.sensorOptions.forEach(item => {
            item.status = false
            sendEquipment0Msg(item.flag)
          })
        }
        this.$emit('selectParkImp', value.status, 1, this.sensorOptions)
      }
      if (index == 2) {
        // sendMonitorMsg(1)
        this.sensorOptions.forEach(item => {
          item.status = false
          sendEquipment0Msg(item.flag)
        })
        if (value.status) {
          this.controlOptions.forEach(item => {
            item.status = true
            sendEquipment1Msg(item.flag)
          })
        } else {
          this.controlOptions.forEach(item => {
            item.status = false
            sendEquipment0Msg(item.flag)
          })
        }
        this.$emit('selectParkImp', value.status, 2, this.controlOptions)
      }
      if (value.status) {
        this.showThrSetting = true
      } else this.showThrSetting = false

      //企业分布
      if (index == 0) {
        sendDistributionMsg(value.status ? 1 : 0)
        this.$emit('selectParkImp', value.status, 0)
        this.controlOptions.forEach(item => {
          item.status = false
          sendEquipment0Msg(item.flag)
        })
        this.sensorOptions.forEach(item => {
          item.status = false
          sendEquipment0Msg(item.flag)
        })
      }
    },
    //传感器点击事件
    sensorClick(value) {
      this.resetRoam()
      this.resetModel()
      // this.sensorOptions.forEach(item => {
      //   if (item != value) {
      //     item.status = false
      //   }
      // })
      this.thematicOptions.forEach(item => {
        item.status = false
      })
      // this.thematicOptions[1].status = true
      this.controlOptions.forEach(item => {
        item.status = false
        sendEquipment0Msg(item.flag)
      })
      value.status = !value.status
      if (value.status) {
        sendEquipment1Msg(value.flag)
      } else sendEquipment0Msg(value.flag)
      var allTrue = true
      var allFalse = false
      this.sensorOptions.forEach(item => {
        if (!item.status) {
          allTrue = false
        }
        if (item.status) {
          allFalse = true
        }
      })
      if (allTrue) {
        this.thematicOptions[1].status = true
      }
      if (this.thematicOptions[0].status) {
        this.thematicOptions[0].status = false
        sendDistributionMsg(0)
      }
      // sendSensorMsg(value.flag)
      this.$emit('selectParkImp', allFalse, 1, this.sensorOptions)
    },
  },
}
</script>
<style lang="scss" scoped>
.thematic-map {
  position: absolute;
  width: 100%;
  height: 100px;
  background-size: 100% 100%;
  background-image: url("@/assets/icon_title.png");
  z-index: 3;
}
.settingC {
  margin-top: 50px;
  margin-left: 50px;
  display: flex;
  width: 210px;
  flex-direction: column;

  &_title1 {
    margin-left: 10px;
    width: 190px;
    height: 24px;
    margin-top: 14px;
    display: flex;
    flex-direction: row;
    align-items: center;
    background-size: 100% 100%;
    background-image: url("@/assets/bg_title1.png");

    span {
      height: 24px;
      font-size: 13px;
      font-family: Source Han Sans SC;
      font-weight: bold;
      color: #FFFFFF;
      margin-left: 11px;
      line-height: 24px;
      background: linear-gradient(0deg, #90CCFF 0%, #FAFAFB 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }
  }

  &_roam {
    width: 100%;
    background-image: url("@/assets/title/bg_settingitem.png");
    background-size: 100% 100%;
    height: 200px;

    &_C {
      margin-top: 10px;
      height: 140px;
      display: flex;
      flex-direction: column;
      overflow-y: auto;

      &_name {
        margin-left: 15px;
        width: 169px;
        margin-bottom: 13px;
        font-size: 13px;
        font-family: PingFang-SC-Regular-, PingFang-SC-Regular;
        font-weight: normal;
        color: #D8E8EC;
      }
    }
  }

  &_model {
    margin-top: 16px;
    width: 100%;
    background-image: url("@/assets/title/bg_settingitem.png");
    background-size: 100% 100%;
    height: 180px;

    &_type {
      width: 40%;
      margin-left: 5%;
      margin-right: 5%;
      margin-top: 7px;
      text-align: center;
      margin-bottom: 7px;
      height: 23px;
      cursor: pointer;
      line-height: 23px;
      font-size: 13px;
      font-family: PingFang-SC-Regular-, PingFang-SC-Regular;
      font-weight: normal;
      color: #D8E8EC;
    }

    &_C {
      height: 100px;
      display: flex;
      flex-direction: column;
      overflow-y: auto;

      &_name {
        margin-left: 15px;
        width: 169px;
        margin-bottom: 7px;
        font-size: 13px;
        font-family: PingFang-SC-Regular-, PingFang-SC-Regular;
        font-weight: normal;
        color: #D8E8EC;
      }
    }
  }

  &_thematic {
    width: 100%;
    margin-top: 15px;
    background-image: url("@/assets/title/bg_settingitem.png");
    background-size: 100% 100%;
    height: 220px;

    &_marginL {
      margin-left: 21px;
    }

    &_C {
      margin-top: 7px;
      height: 170px;
      display: flex;
      flex-direction: column;
      overflow-y: auto;

      &_item {
        margin-top: 7px;
        display: flex;
        position: relative;
        flex-direction: row;
        align-items: center;

        &_icon {
          margin-left: 11px;
          width: 10px;
          height: 10px;
          background-size: 100% 100%;
        }

        &_iconc {
          margin-left: 32px;
          width: 10px;
          height: 10px;
          background-size: 100% 100%;
        }

        &_name {
          margin-left: 9px;
          height: 17px;
          font-size: 13px;
          font-family: PingFang-SC-Regular-, PingFang-SC-Regular;
          font-weight: normal;
          color: #D8E8EC;
          line-height: 17px;
        }
      }

    }
  }
}
</style>